27/09/2018
"Stone Age" (painting by Viktor Mikhailovich Vasnetsov, public domain).
Old Egyptian hieroglyphic painting showing an early instance of a domesticated animal. (public domain).
Sumerian contract: selling of a field and a house. Shuruppak, pre-cuneiform script. Shuruppak, 2600 BC. (Picture by Marie-Lan Nguyen 2005, public domain).
More advanced economy:
More advanced economy: more data to handle
How does the abacus work?
A simple abacus. Source: Hogben (1983).
The example in more detail:
\(139=(1 \times 10^{2}) + (3 \times 10^{1}) + (9 \times 10^{0})\)
Microprocessors can only represent two signs (states):
010, 1.What is the decimal number 139 in the binary counting frame?
What is the decimal number 139 in the binary counting frame?
\[(1 \times 2^7) + (1 \times 2^3) + (1 \times 2^1) + (1 \times 2^0) = 139.\]
What is the decimal number 139 in the binary counting frame?
\[(1 \times 2^7) + (1 \times 2^3) + (1 \times 2^1) + (1 \times 2^0) = 139.\]
\[(1 \times 2^7) + (0 \times 2^6) + (0 \times 2^5) + (0 \times 2^4) + (1 \times 2^3)\\ + (0 \times 2^2) + (1 \times 2^1) + (1 \times 2^0) = 139.\]
139 in the decimal system corresponds to 10001011 in the binary system.If computers only understand 0 and 1, how can they express decimal numbers like 139?
If computers only understand 0 and 1, how can they express decimal numbers like 139?
0/1 switch).| Number | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| 0 = | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 = | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
| 2 = | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
| 3 = | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |
| … | ||||||||
| 139 = | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 |
16 symbols:
0-9 (used like in the decimal system)…and A-F (for the numbers 10 to 15).
16 symbols: base 16: each digit represents an increasing power of 16 (\(16^{0}\), \(16^{1}\), etc.).
What is the decimal number 139 expressed in the hexadecimal system?
What is the decimal number 139 expressed in the hexadecimal system?
What is the decimal number 139 expressed in the hexadecimal system?
Solution: \[(8\times 16^1) + (11\times 16^0) = 139.\]
More precisely: \[(8\times 16^1) + (B\times 16^0) = 8B = 139.\]
What is the decimal number 139 expressed in the hexadecimal system?
Solution: \[(8\times 16^1) + (11\times 16^0) = 139.\]
More precisely: \[(8\times 16^1) + (B\times 16^0) = 8B = 139.\]
Hence: 10001011 (in binary) = 8B (in hexadecimal) = 139 in decimal.
Advantages (when working with binary numbers)
Advantages (when working with binary numbers)… Why?
8B (in hexadecimal) = 10001011 (1000 1011) in binary.How can a computer understand text if it only understands 0s and 1s?
A modified version of South Korean Dubeolsik (two-set type) for old hangul letters. (Illustration by Yes0song 2010, Creative Commons Attribution-Share Alike 3.0 Unported)
How can a computer understand text if it only understands 0s and 1s?
0s and 1s correspond to specific letters/characters of different human languages.ASCII logo. (public domain).
| Binary | Hexadecimal | Decimal | Character |
|---|---|---|---|
| 0011 1111 | 3F | 63 | ? |
| 0100 0001 | 41 | 65 | A |
| 0110 0010 | 62 | 98 | b |
Two core themes of this course:
Two core themes of this course:
In both of these domains we mainly work with one simple type of document: text files.
0s and 1s)! Install RStudio from here!
Install Atom from here!
The 'blackbox' of data processing.
Basic components of a standard computing environment. Figure by Murrell (2009) (Figure 9.1, licensed under CC BY-NC-SA 3.0 NZ).
Recall the initial example (survey) of this course.
Access a website (over the Internet), use keyboard to enter data into a website (a Google sheet in that case).
R program accesses the data of the Google sheet (again over the Internet), download the data, and load it into RAM.
Data processing: produce output (in the form of statistics/plots), output on screen.
Components involved in 'visiting' a website. Figure by Murrell (2009) (licensed under CC BY-NC-SA 3.0 NZ)
Data involved involved in 'visiting a website'. Figure by Murrell (2009) (licensed under CC BY-NC-SA 3.0 NZ)
Download the website (read its source code into RAM)
clockHTML <- readLines("https://www.census.gov/popclock/")
Have a look at the first lines of the webpage's source code:
head(clockHTML)
## [1] "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" ## [2] " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" ## [3] "<html lang=\"en\">" ## [4] "<head>" ## [5] "\t<title>Population Clock</title>" ## [6] " <meta charset=\"UTF-8\">"
Search the source code for the line that contains the part of the website with the world population counter:
line_number <- grep('id="world-pop-container"', clockHTML)
We can now check on which line the text was found.
line_number
## [1] 4611
Accessing data in RAM, processing it, and storing the result in RAM. Figure by Murrell (2009) (licensed under CC BY-NC-SA 3.0 NZ).
writeLines(clockHTML, "clock.html")
Writing data stored in RAM to a Mass Storage device (hard drive). Figure by Murrell (2009) (licensed under CC BY-NC-SA 3.0 NZ).
Hogben, Lancelot. 1983. Mathematics for the Million. New York: W.W Norton & Company.
Murrell, Paul. 2009. Introduction to Data Technologies. London, UK: CRC Press.